package com.mdd.admin.controller;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.ILegalUserWithdrawService;
import com.mdd.admin.validate.LegalUserWithdrawSearchValidate;
import com.mdd.admin.validate.LegalUserWithdrawStatusUpdateValidate;
import com.mdd.admin.validate.LegalUserWithdrawUpdateValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.vo.LegalUserWithdrawDetailVo;
import com.mdd.admin.vo.LegalUserWithdrawListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/withdraw")
@Api(tags = "提现表管理")
public class LegalUserWithdrawController {

    @Resource
    ILegalUserWithdrawService iLegalUserWithdrawService;

    @GetMapping("/list")
    @ApiOperation(value="提现表列表")
    public AjaxResult<PageResult<LegalUserWithdrawListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated LegalUserWithdrawSearchValidate searchValidate) {
        PageResult<LegalUserWithdrawListedVo> list = iLegalUserWithdrawService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="提现表详情")
    public AjaxResult<LegalUserWithdrawDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        LegalUserWithdrawDetailVo detail = iLegalUserWithdrawService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "提现表编辑")
    @PostMapping("/edit")
    @ApiOperation(value="提现表编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody LegalUserWithdrawUpdateValidate updateValidate) {
        iLegalUserWithdrawService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "状态编辑")
    @PostMapping("/editStatus")
    @ApiOperation(value="状态编辑")
    public AjaxResult<Object> editStatus(@Validated @RequestBody LegalUserWithdrawStatusUpdateValidate updateValidate) {
        iLegalUserWithdrawService.editStatus(updateValidate);
        return AjaxResult.success();
    }


}
